package eu.log.db;

import java.util.Date;
import eu.log.Rank;

/**
 * 日志实体,应包括以下内容
 * ClientIdentity 客户身份标识,如应用在Web环境中,可以用IP来标识客户.
 * Event 记录事件,是日志的主体内容.
 * Time 事件发生时间.
 * Rank 时间等级.
 * @author 吴振振
 * @version 1.0 alpha
 */
public class LogEntity implements eu.log.Log{
	String clientIdentity;
	String event;
	long time;
	Rank rank;	
	
	LogEntity(String clientIdentity, String event, long time, Rank rank) {
		this.clientIdentity = clientIdentity;
		this.event = event;
		this.time = time;
		this.rank = rank;
	}

	LogEntity(String clientIdentity, String event, Date time, Rank rank) {
		this.clientIdentity = clientIdentity;
		this.event = event;
		this.time = time.getTime();
		this.rank = rank;
	}
	
	LogEntity() {
	}

	/**
	 * 获取客户身份标识
	 */
	public String getClientIdentity(){
		return clientIdentity;
	}

	/**
	 * 设置客户身份标识
	 * @param clientIdentity
	 */
	public void setClientIdentity(String clientIdentity){
		this.clientIdentity=clientIdentity;
	}

	/**
	 * 获取事件
	 */
	public String getEvent(){
		return event;
	}

	/**
	 * 设置事件.
	 * @param event
	 */
	public void setEvent(String event){
		this.event=event;
	}

	/**
	 * 获取事件发生时间.
	 */
	public long getTime(){
		return time;
	}
	
	/**
	 * 设置事件 发生时间
	 * @param time
	 */
	public void setTime(Date time){
		this.time=time.getTime();
	}

	/**
	 * 设置事件 发生时间
	 * @param time
	 */
	public void setTime(long time){
		this.time=time;
	}
	
	/**
	 * 获取事件等级
	 */
	public Rank getRank(){
		return rank;
	}

	/**
	 * 设置事件等级
	 * @param rank
	 */
	public void setRank(Rank rank){
		this.rank=rank;
	}

	@Override
	public String toString() {
		return time+" "+rank+" ["+clientIdentity+"] "+event;
	}

}
